Comments on Category Theory for Programmers

 

2 Comments.

from the YouTube video "Category Theory 1.1: Motivation and Philosophy" by Bartosz Milewski

  • key concepts: composability & abstraction
  • object-oriented programming: objects hide data and share data (which breaks composability); functional programming: no mutatability, no data races, full composability
  • some ideas are simple, but complex to express in certain languages; they often involve high levels of abstraction ...
  • "Category Theory is this higher-level language above Haskell, above functional programming, above ML, or Scala, or C++. ... It's not a practical language that we can write code in, but it's a language. ... These ideas can percolate down. .. So we want to get to this highest possible level of abstraction to help us express ideas that later can be translated into programs."
  • "Category Theory unifies lots of things. ... If you abstract enough, if you chop off all the unnecessary stuff, if you are at the top of Mount Everest and looking down, suddenly all these things start looking similar. From that high level all these programming languages look like little ants and they behave the same way. All this programming stuff is the same. But that's not all. Suddenly, at this high high level, other things look the same. Mathematicians discovered this. They developed geometry, algebra, number theory, topology, set theory. These are all completely different theories. They look nothing like each other. And Category Theory found out similarities between all these things. ... So there is this grand unification of all areas of mathematics within Category Theory."
  • And there are programming languages, and data structures, bunches of bytes and pointers between bunches of bytes. Very low-level, like plumbers working with tubes. And then computer scientists realized that all these things form types. And all these areas of mathematics are the same - the Curry-Howard-Lambek Isomorphism among logic, computation, and Category Theory. [1]
  • We are humans, we are evolved monkeys. Some parts of our brains have evolved to analyze visual inputs. We learned to distinguish between predator and food, and got very good at it. Image recognition is a very hard problem but we've been working on it for a billion years and our brains are good at it. There are other things have evolved for only a very short time - counting, communicating, organizing stuff, math, science - for the last few thousand years, only. These brains haven't evolved to do programming or mathematics. They evolved to find food. So compared to the complexity of our visual cortex, this newly-acquired ability to use language is primitive and simple. We are using this tool to do mathematics, and things we found useful in doing abstract mathematics came from things that worked for finding food - decomposing things into simpler problems, solving them, and combining them. This is how we work, and how we do science too. We can only do these things that have a similar structure. If they don't have this structure, we can't do them. Maybe everything in the universe can be chopped into little pieces and then recomposed. Maybe that's the basic structure of the universe and our brains reflect that. But maybe not. Decomposition and combining seemed to work for physics, for a while. But the simpler things have to have simpler properties. If they don't then the decomposition doesn't work. Maybe Nature doesn't follow this pattern. Maybe the most elementary things aren't points, like in string theory. And in the other way, in quantum mechanics, multiparticle states aren't just composition of single-particle states - they have properties that aren't separable. Maybe composability is a property of our brains, not of Nature. So in this way, Category Theory is about how our brains work, our minds. Not about mathematics or physics. Category Theory is more of epistemology, not ontology.

– ^z 2019-02-03


from the YouTube video "Category Theory 1.2: What is a category?" by Bartosz Milewski

  • The major tools in our arsenal are:

  • abstraction - getting rid of unnecessarily details - so things that used to be different become identical (for some purposes - an area of mathematics - homotype theory) * composition * identity
  • * Composition and Identity define Category Theory

    • "From a set-theorists's viewpoint, everything is a set. They have a set-hammer, and everything is a set-nail!"
    • a Category consists of

  • objects (dots, points that have no properties, no purpose except to be names for the ends of arrows) * morphisms (arrows that go between two objects)
  • * "We perceive the universe through notions that were developed by hunter-gatherers. They described the world in terms of spatial relationships. ... Above, below. Movement. Relationships."

    • What kinds of things can happen? You can have zero or more arrows going between objects.
    • Composition is the property that if you have an arrow "f" from "a" to "b" and another arrow "g" from "b" to "c" ... then there always must exist an arrow that is the composition of these ... "g∘f" from "a" to "c" (read it as "g after f")
    • Identity is the property that for every object there is an arrow to itself, one per object.
    • Associativity is the property that you can compose arrows in different ways to get the same result: f∘(g∘h) = (f∘g)∘h
    • footnote: "bottom" is a special value in Haskell that is the returned type of an infinite calculation
    • footnote: in programming, "types" can be "sets of values" and functions can be arrows (morphisms) between those sets of values
    • footnote: a lot of categories come from some model - like the category of Set - there are details about sets and their elements - but when building a category on something we have to have amnesia, we have to forget about the structures of the underlying model - use this information to create a big infinite-dimensional multiplication table and then forget it - "I'm abstracting, I'm forgetting information left and right ... I have these objects, I forget where they came from, I have these arrows, I forget where they came from ... and now we can start thinking about what we can say about these objects, just by looking at morphisms - and it turns out we can say a lot of things!" - so for instance, one can identify an empty set just from looking at its morphisms, nothing else, and likewise a single-element set ... " - If you think about what's inside a set, you're thinking assembly language, thinking about elements and how they are mapped. In category theory you're thinking in a higher level language. You don't have to look inside the set. You just have to look at how they're connected with arrows. It's the ultimate in data hiding. This is the end of the road for abstraction.

    next https://youtu.be/O2lZkr-aAqk = Category Theory 2.1: Functions, epimorphisms

    – z 2019-02-03 22:41 UTC</div>